home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group93c.txt / 000051_icon-group-sender _Mon Sep 13 10:00:24 1993.msg < prev    next >
Internet Message Format  |  1994-02-02  |  2KB

  1. Received: from owl.CS.Arizona.EDU by cheltenham.cs.arizona.edu; Mon, 13 Sep 1993 09:47:15 MST
  2. Received: by owl.cs.arizona.edu; Mon, 13 Sep 1993 09:47:14 MST
  3. Date: Mon, 13 Sep 1993 10:00:24 -0600 (CST)
  4. From: Chris Tenaglia - 257-8765 <TENAGLIA@MIS.MCW.EDU>
  5. Subject: Re: newbie question
  6. To: icon-group@cs.arizona.edu
  7. Message-Id: <01H2W8U4NC428WWTKA@mis.mcw.edu>
  8. Organization: Medical College of Wisconsin (Milwaukee, WI)
  9. X-Vms-To: IN%"icon-group@cs.arizona.edu"
  10. Mime-Version: 1.0
  11. Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
  12. Content-Transfer-Encoding: 7BIT
  13. Status: R
  14. Errors-To: icon-group-errors@cs.arizona.edu
  15.  
  16. > From:    IN%"news-feed-1.peachnet.edu!news-feed-2.peachnet.edu!umn.edu!lynx.unm.edu!dns1.NMSU.Edu!cymorg@gatech.edu" 13-SEP-1993 09:42:19.58
  17. > To:    IN%"icon-group@cs.arizona.edu"
  18. > Subj:    another newbie question (simple)
  19.  
  20. >     I have another easy to solve (i hope) problem, that i can't
  21. > figure out simply because I dont have any documentation nor
  22. > the money to get the book I so dearly need.  I would like
  23. > to somehow take a string s, and rewrite it, say (for example)
  24. > as a new string with each letter being the letter following
  25. > the one in the original word....ie:
  26.  
  27. > hello, becomes: ifmmp
  28.  
  29. > how would I do this in icon?  
  30.  
  31. > Thanx,
  32. > Chris
  33. > -- 
  34. > **--**         Woman don't you know with you i'm born again       **--**
  35. > >                                    <
  36. > >            Chris Fagyal                    <
  37. > >            Cymorg@acca.nmsu.edu                <
  38.  
  39. This can be easily done using the map() expression:
  40.  
  41. #
  42. # this rotates the characterset in a string.
  43. # input : is the input string
  44. # shift : is the amount of rotation (0 < shift 256)
  45. # use   : newstring := rotn(oldstring,13)   # to do ROT13 for example
  46. #
  47. procedure rotn(input,shift)
  48.   static  transpose
  49.   initial transpose := string(&cset) || string(&cset)
  50.   translate := transpose[shift+:256]
  51.   return map(input,&cset,translate)
  52.   end
  53.  
  54. map() takes an input string and two mapping strings that must be of equal
  55. length. Without the mapping strings specified, it defaults to a convert
  56. all strings to lower case. The static and initial make transpose permanent
  57. storage and evaluates it only once (the first time).
  58.  
  59. Chris Tenaglia (System Manager) |  "The past explained,     
  60. Medical College of Wisconsin    |   the future fortold, 
  61. 8701 W. Watertown Plank Rd.     |   the present largely appologized for."
  62. Milwaukee, WI 53226             |   Organon to The Doctor
  63. (414)257-8765                   |     
  64. tenaglia@mis.mcw.edu
  65.  
  66.